﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PatientScheduler.aspx.cs"
    Inherits="PatientScheduler" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>دریافت نوبت</title>
    <style type="text/css">
        .Disabled
        {
            background-color: Grey !important;
        }
        .Enabled
        {
            background-color: Red !important;
        }
        .RadScheduler .rsAptSubject
        {
            text-align: right;
            padding: 4px 0 1px;
            margin: 0 0 3px;
            font-size: 12px;
            font-weight: bold;
            color: #369;
            height: 17px;
            border-bottom: 1px solid #99DEFD;
            width: 100%;
        }
        
        .RadScheduler .rsAdvancedEdit .RadColorPicker label
        {
            text-align: right;
            display: block;
            padding: 0;
        }
    </style>
    <script type="text/javascript">
        function OnClientAppointmentEditing(sender, eventArgs) {
            eventArgs.set_cancel(true);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: center">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="DoctorScheduler">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="DoctorScheduler" LoadingPanelID="RadAjaxLoadingPanel1">
                        </telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1"
            CssClass="exampleContainer">
            <telerik:RadComboBox runat="Server" ID="GroupingDirectionComboBox" Skin="Vista" OnSelectedIndexChanged="GroupingDirectionComboBox_SelectedIndexChanged"
                AutoPostBack="True">
                <Items>
                    <telerik:RadComboBoxItem Text="افقی" Value="Horizontal"></telerik:RadComboBoxItem>
                    <telerik:RadComboBoxItem Text="عمودی" Value="Vertical"></telerik:RadComboBoxItem>
                </Items>
            </telerik:RadComboBox>
            :نمایش به صورت
            <telerik:RadScheduler runat="server" ID="PatientsScheduler" Width="100%" Height="100%"
                GroupBy="Doctor" AppointmentStyleMode="Default" DataSourceID="PatientAppointmentsEntityDataSource"
                DataKeyField="Id" DataSubjectField="Id" DataStartField="Start" DataEndField="End"
                OnResourceHeaderCreated="PatientsScheduler_ResourceHeaderCreated" 
                OnAppointmentDataBound="PatientsScheduler_AppointmentDataBound" 
                OnFormCreating="PatientsScheduler_FormCreating" EditFormDateFormat="yyyy/MM/dd"
                EditFormTimeFormat="h:mm" FirstDayOfWeek="Saturday" HoursPanelTimeFormat="H:mm"
                LastDayOfWeek="Thursday" StartInsertingInAdvancedForm="True" TimeZoneID="Iran Standard Time"
                TimeZoneOffset="03:30:00" WorkDayEndTime="18:00:00" OnTimeSlotCreated="PatientsScheduler_TimeSlotCreated"
                OnClientAppointmentEditing="OnClientAppointmentEditing" 
                SelectedDate="03/17/2013 01:00:00">
                <ResourceHeaderTemplate>
                    <asp:Panel ID="ResourceImageWrapper" runat="server" CssClass="ResCustomClass">
                        <asp:Image ID="DoctorImage" runat="server"></asp:Image>
                    </asp:Panel>
                </ResourceHeaderTemplate>
                <Reminders Enabled="true" />
                <AppointmentTemplate>
                    <div class="rsAptSubject">
                        <%# Eval("Id") %>
                    </div>
                </AppointmentTemplate>
                <AdvancedInsertTemplate>
                    <div id="qsfexAdvEditWrapper" dir="rtl">
                        <div id="qsfexAdvEditInnerWrapper" class="technical">
                            <div class="qsfexAdvAppType">
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label4" AssociatedControlID="PatientComboBox" runat="server" CssClass="inline-label">نام و نام خانوادگی بیمار: </asp:Label>
                                <telerik:RadComboBox runat="server" ID="PatientComboBox" DataTextField="Name" DataValueField="Id"
                                    Width="90%" Skin="Office2007" DataSourceID="PatientsEntityDataSource" SelectedValue='<%# Bind("PatientId") %>'>
                                </telerik:RadComboBox>
                                <br />
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label5" AssociatedControlID="StartInput" runat="server" CssClass="inline-label">زمان شروع:</asp:Label>
                                <telerik:RadDateInput ID="StartInput" SelectedDate='<%# Bind("Start") %>' runat="server"
                                    EnableSingleInputRendering="false">
                                </telerik:RadDateInput>
                                <br />
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label6" AssociatedControlID="EndInput" runat="server" CssClass="inline-label">زمان پایان:</asp:Label>
                                <telerik:RadDateInput ID="EndInput" SelectedDate='<%# Bind("End") %>' runat="server"
                                    EnableSingleInputRendering="false">
                                </telerik:RadDateInput><br />
                            </div>                          
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label2" AssociatedControlID="DoctorAppointmentsComboBox" runat="server" CssClass="inline-label">ملاقات:</asp:Label>
                                <telerik:RadComboBox runat="server" ID="DoctorAppointmentsComboBox" DataTextField="Name" DataValueField="Id"
                                    Width="90%" Skin="Office2007" DataSourceID="DoctorAppointmentsEntityDataSource" SelectedValue='<%# Bind("DoctorAppointmentId") %>'>
                                </telerik:RadComboBox>
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                                    <asp:Image runat="server" ID="Image4" ValidationGroup="Insert" ImageUrl="App_Themes/Default/Images/ok.png"
                                        AlternateText="insert"></asp:Image></asp:LinkButton>
                                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Style="margin-right: 8px;">
                                    <asp:Image runat="server" ID="Image5" ImageUrl="App_Themes/Default/Images/cancel.png"
                                        AlternateText="cancel"></asp:Image></asp:LinkButton>
                            </div>
                        </div>
                    </div>
                </AdvancedInsertTemplate>
                <AdvancedForm DateFormat="yyyy/MM/dd" TimeFormat="h:mm" Width="100%" />
                <ResourceTypes>
                    <telerik:ResourceType KeyField="Id" Name="DoctorAppointment" TextField="Name" ForeignKeyField="DoctorAppointmentId"
                        DataSourceID="DoctorAppointmentsEntityDataSource"></telerik:ResourceType>                  
                    <telerik:ResourceType KeyField="Id" Name="Patient" TextField="Name" ForeignKeyField="PatientId"
                        DataSourceID="PatientsEntityDataSource"></telerik:ResourceType>
                </ResourceTypes>
                <ResourceStyles>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="1" BackColor="#eb901b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="2" BackColor="#8fd21b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="3" BackColor="#278ce9"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="4" BackColor="#f14db2"></telerik:ResourceStyleMapping>
                </ResourceStyles>
                <TimelineView UserSelectable="false" />
                <TimeSlotContextMenuSettings EnableDefault="true" />
                <AppointmentContextMenuSettings EnableDefault="true" />
            </telerik:RadScheduler>
        </telerik:RadAjaxPanel>
        '' 
        <asp:EntityDataSource ID="PatientAppointmentsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" EntitySetName="PatientAppointments" EnableUpdate="true" EnableInsert="True">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="DoctorAppointmentsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities"  CommandText="            
            SELECT DoctorAppointment.Subject,[Room].Name+' '+ [Room].Address+' '+ [Doctor].LastName+' '+ [Doctor].FirstName as Name,
            [DoctorAppointment].Id as Id FROM 
            DatabaseEntities.DoctorAppointments as DoctorAppointment INNER JOIN
            DatabaseEntities.Doctors as Doctor ON 
            DoctorAppointment.DoctorId = Doctor.Id INNER JOIN
            DatabaseEntities.Rooms as Room ON 
            DoctorAppointment.RoomId = Room.Id">                        
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="PatientsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" CommandText="SELECT it.[Id] , it.[FirstName] + ' ' + it.[LastName] as Name From DatabaseEntities.Patients as it">
        </asp:EntityDataSource>
    </div>
    </form>
</body>
</html>
